<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Ajax-Login-Index</title>
    <script type="text/javascript" src="/jsp/jquery-3.2.1.min.js"></script>
</head>
<body>
<div align="center">
    <s:i18n name="mess">
        <form method="POST" id="loginForm">
            <s:textfield key="user" labelposition="left" name="user.name"/><br/>
            <s:textfield key="pass" labelposition="left" name="user.pass"/><br/>
            <input type="button" id="loginBn" value='<s:text name="login"/>'/>
        </form>
    </s:i18n>
    <div id="show" style="display: none;">
    </div>
</div>

<script type="text/javascript">
    $("#loginBn").click(
      function () {
          $("#show").hide();
          $.get("ajax-login",$("#loginForm").serializeArray(),
              function (data, statusText) {
                  $("#show").height(80).width(240)
                      .css("border","1px solid black")
                      .css("border-radius","15px")
                      .css("background-color","#efef99")
                      .css("color","#ff0000")
                      .css("padding","20px")
                      .empty();
                  $("#show").append("登录结果："+data+"<br/>");
                  $("#show").show(600);
              }
          );
      }
    );
</script>
</body>
</html>
